package actions;

import jason.asSemantics.DefaultInternalAction;
import jason.asSemantics.TransitionSystem;
import jason.asSemantics.Unifier;
import jason.asSyntax.NumberTerm;
import jason.asSyntax.Term;
import jason.environment.grid.Location;
import ecomp.architecture.EcompArch;
import ecomp.models.LocalWorldModel;

@SuppressWarnings("serial")
public class inside_corral extends DefaultInternalAction{
	
	EcompArch arch;
	LocalWorldModel localWorldModel;
	
	@Override
	public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
		
		arch = (EcompArch) ts.getUserAgArch();
		localWorldModel = arch.localWorldModel;
		Term x = args[0];
		Term y = args[1];
		
		// Unfold terms
		int xValue = (int) ((NumberTerm)x).solve();
		int yValue = (int) ((NumberTerm)y).solve();
		
		un.unifies(x, x);
		un.unifies(y, y);
		boolean retDebug = localWorldModel.inCorral(new Location(xValue,yValue));
		return retDebug;
	}
}